package org.gpslw.autoconfig;

import com.bedatadriven.jackson.datatype.jts.serialization.GeometrySerializer;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

/**
 * 第三方的序列化器的全局配置，如果是自定义的可以直接使用JsonComponent直接配置
 */
@Order(Ordered.LOWEST_PRECEDENCE)
@Configuration
public class ObjectMapperConfig implements Jackson2ObjectMapperBuilderCustomizer {

    @Override
    public void customize(Jackson2ObjectMapperBuilder builder) {
        //本质上是添加了一个GeometrySerializer序列化器
        builder.serializers(new GeometrySerializer());
        builder.serializers(new org.geolatte.geom.json.GeometrySerializer());
    }
}
